
#include "stext.h"
#include "machinfo.h"
#include <stdio.h>
#include <stdlib.h>

char *ptxt = "processor	: 0\r\n\
vendor_id	: GenuineIntel\r\n\
cpu family	: 6\r\n\
model		: 42\r\n\
model name	: Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz\r\n\
stepping	: 7\r\n\
cpu MHz		: 2691.379\r\n\
cache size	: 4096 KB\r\n\
fpu		: yes\r\n\
fpu_exception	: yes\r\n\
cpuid level	: 13\r\n\
wp		: yes\r\n\
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts nopl xtopology tsc_reliable nonstop_tsc aperfmperf pni pclmulqdq vmx ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx hypervisor lahf_lm ida arat epb xsaveopt pln pts dts tpr_shadow vnmi ept vpid\r\n\
bogomips	: 5382.75\r\n\
clflush size	: 64\r\n\
cache_alignment	: 64\r\n\
address sizes	: 40 bits physical, 48 bits virtual\r\n\
power management:";

char *pstat = "cpu  368 0 1021 4056 699 0 9 0 0 0\r\n\
cpu0 368 0 1021 4056 699 0 9 0 0 0\r\n\
intr 8596 72 8 0 0 0 0 3 0 1 0 0 0 136 0 0 47 0 2214 141 353 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\r\n\
ctxt 20617\r\n\
btime 1335440369\r\n\
processes 1068\r\n\
procs_running 2\r\n\
procs_blocked 0\r\n\
softirq 14611 0 4082 9 353 2140 0 36 0 0 7991";


char *pdev = "Inter-|   Receive                                                |  Transmit\r\n\
 face |bytes    packets errs drop fifo frame compressed multicast|bytes    packets errs drop fifo colls carrier compressed\r\n\
     lo:       0       0    0    0    0     0          0         0        0       0    0    0    0     0       0          0\r\n\
       eth0:   21603     209    0    0    0     0          0         0    27325     187    0    0    0     0       0          0";


struct TEST {
	int a;
	int b;
	int c;
	char d[40000];
	long h[40000]; 
	int k[40000];
};
int main(void) {
	struct KVPair *pkv =  api_textToKV(ptxt, " \t\r:");
	struct KVPair *pkv2;
	for(pkv2=pkv; pkv2!=NULL; pkv2= pkv2->pnext) {
		//getchar();
		printf("key:%s, value:%s\n", pkv2->akey, pkv2->avalue);
	}

	struct XML *pxml= (struct XML*)MALLOC(sizeof(struct XML));
	printf("%s", getCpuXml(pxml));

	struct XML *pxml2= (struct XML*)MALLOC(sizeof(struct XML));
	getMemXml(pxml2);
	printf("%s", pxml2->xml_string.phead);

	struct ListNode *phead = textToList(pstat, " \t\r\n");
	for(;phead!=NULL;phead=phead->pnext) {
		printf("%d:%s\t", phead->type, phead->avalue);
	}

	phead = textToList(pdev, " \t\r\n");
	for(;phead!=NULL;phead=phead->pnext) {
		printf("%d:%s\t", phead->type, phead->avalue);
	}

	struct XML *pxml3 = (struct XML*)MALLOC(sizeof(struct XML) * sizeof(char));
	getStatXml(pxml3);
	printf("%s\n", pxml3->xml_string.phead);

	struct XML *pxml4 = (struct XML*)MALLOC(sizeof(struct XML) * sizeof(char));
	getNetXml(pxml4);
	printf("%s\n", pxml4->xml_string.phead);
	
	return 0;

}


